import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'

Vue.use(VueRouter);

const HelloWorld = () => import('../components/HelloWorld.vue');

export const constantRoutes = [
  {
    path: '',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: '/index',
        component: () => import('../views/index.vue'),
        name: '首页',
        meta: {title: '首页', icon: 'dashboard', noCache: true, affix: true}
      }
    ]
  },
  {
    path: '/hello',
    meta: {
      title: '欢迎页'
    },
    component: HelloWorld
  },
  {
    path: '/login',
    meta: {
      title: '登录'
    },
    component: () => import('../views/Login.vue'),
  },
  {
    path: '',
    meta: {
      title: '欢迎页'
    },
    component: () => require(['../components/index.vue'])
  },
  // {
  // 	path: '/index',
  // 	meta: {
  // 		title: '首页'
  // 	},
  // 	component: () => () => import('../components/index.vue')
  // },
];

export default new VueRouter({
  mode: 'history', // 去掉url中的#
  scrollBehavior: () => ({x: 0, y: 0}),
  routes: constantRoutes
})
